gtkwindow: apply CSD adjustments to the default size when used instead of when setting it
authorChristoph Reiter <creiter@src.gnome.org>
Wed, 18 Nov 2015 18:17:01 +0000 (19:17 +0100)
committerChristoph Reiter <creiter@src.gnome.org>
Thu, 19 Nov 2015 20:42:24 +0000 (21:42 +0100)
Before the resulting window size would differ if the default size was set
before adding a headerbar vs after. Now the saved state is again the actual
requested size and it is adjusted at the time we request a window size.

https://bugzilla.gnome.org/show_bug.cgi?id=756618

gtk/gtkwindow.c

index f87acd9b60380eb415fcda23218473613424155c..309a1fec59f1e1108f95a0db12011a97b0098024 100644 (file)
@@ -5232,7 +5232,6 @@ gtk_window_set_default_size (GtkWindow   *window,
   g_return_if_fail (width >= -1);
   g_return_if_fail (height >= -1);
 
-  gtk_window_update_csd_size (window, &width, &height, INCLUDE_CSD_SIZE);
   gtk_window_set_default_size_internal (window, TRUE, width, TRUE, height, FALSE);
 }
 
@@ -5278,20 +5277,16 @@ gtk_window_get_default_size (GtkWindow *window,
                             gint      *height)
 {
   GtkWindowGeometryInfo *info;
-  gint w, h;
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   info = gtk_window_get_geometry_info (window, FALSE);
-  w = info ? info->default_width : -1;
-  h = info ? info->default_height : -1;
-  gtk_window_update_csd_size (window, &w, &h, EXCLUDE_CSD_SIZE);
 
   if (width)
-    *width = w;
+    *width = info ? info->default_width : -1;
 
   if (height)
-    *height = h;
+    *height = info ? info->default_height : -1;
 }
 
 /**
@@ -5827,9 +5822,6 @@ gtk_window_get_position (GtkWindow *window,
     }
 }
 
-#undef INCLUDE_CSD_SIZE
-#undef EXCLUDE_CSD_SIZE
-
 /**
  * gtk_window_reshow_with_initial_size:
  * @window: a #GtkWindow
@@ -8996,10 +8988,19 @@ gtk_window_compute_configure_request_size (GtkWindow   *window,
       /* Override with default size */
       if (info)
         {
+          /* Take width of shadows/headerbar into account. We want to set the
+           * default size of the content area and not the window area.
+           */
+          gint default_width_csd = info->default_width;
+          gint default_height_csd = info->default_height;
+          gtk_window_update_csd_size (window,
+                                      &default_width_csd, &default_height_csd,
+                                      INCLUDE_CSD_SIZE);
+
           if (info->default_width > 0)
-            *width = info->default_width;
+            *width = default_width_csd;
           if (info->default_height > 0)
-            *height = info->default_height;
+            *height = default_height_csd;
 
           if (info->default_is_geometry)
             geometry_size_to_pixels (geometry, flags,
@@ -9040,6 +9041,9 @@ gtk_window_compute_configure_request_size (GtkWindow   *window,
   *height = MAX (*height, 1);
 }
 
+#undef INCLUDE_CSD_SIZE
+#undef EXCLUDE_CSD_SIZE
+
 static GtkWindowPosition
 get_effective_position (GtkWindow *window)
 {